								<style type="text/css">

                </style>
                <table id="sample-table-2" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
										     <th class="center"  style="width:3%">
                          <label>
                             <input type="checkbox" class="ace" id="alldel" value=""/>
                             <span class="lbl"></span>
                          </label>
                       </th>
											<th style="width:4%">序号</th>
											<th style="width:8%">51M货号</th>
											<th style="width:10%">条形码</th>
											<th style="width:10%">名称</th>
											<th style="width:8%">商品属性</th>
											<th style="width:10%">价格($)(不含GST)</th>
											<th style="width:8%">GST($)</th>
											<th style="width:8%">公共仓库存</th>
											<th style="width:8%">虚拟仓库存</th>
                      <th style="width:2%">采购数量</th>
											<th style="width:5%">操作</th>
										</tr>
									</thead>
									<tbody>
										<volist name="lists['lists']" id="vo">
											<tr>
                        <td class="center">
                                <input type="checkbox" class="ace enable_disable" onclick="enable_disable(this)" value="{$vo.goods_sn}" />
                                <span class="lbl"></span>
                        
                        </td>
												<td>
													<a href="#">{$i}</a>
												</td>
												<td>{$vo.goods_sn}</td>
												<td>{$vo.bar_code}</td>
												<td>{$vo.goods_name}</td>
												<td>{$vo.attribute_text|default ="/"}</td>
												<td class="price">{$vo.goods_price }</td>
												<td >{$vo.taxrate}</td>
												<td>{$vo.quantity }</td>
												<td>{$vo.my_quantity }</td>
												<td style="width:8%"><input class="number" style="width:80px" value="" min="0" type="number" name="number" disabled="disabled"  ></td>
                                                 <td ><!-- <button type="button" class="btn btn-sm btn-info"  onclick="_es_openDilog90('{:U('Invoice/InvoiceGoodsDetails',array('delivery_id'=>$vo['delivery_id']))}','预收单采购记录','yushoudancaigoujilu')"> 详情</button> -->
                                                 <a type="button" class="btn btn-sm  sub_caigou" disabled="disabled" goodssn ="{$vo.goods_sn}" price="{$vo.goods_price }"  onclick="goods_purchase(this)" url="{:U('Replenishment/goods_purchase',array('goods_sn'=>$vo['goods_sn']))}" > 采购</a>

                                                 <!-- <button type="button" class="btn btn-sm btn-info"  onclick="_es_openDilog90('{:U('Replenishment/goods_purchase_htm',array('goods_sn'=>$vo['goods_sn']))}','补货采购','buhuocaigou')"> 采购</button> --></td>
                                               
											</tr>
										</volist>
									</tbody>
								</table>
							
					<table style="width: 80%; float: right; margin-bottom:10px">
					    <tr>
					        <td style="text-align: right;"> <div class="page_list_ops dataTables_paginate paging_bootstrap pagination" >{$lists['page_html']}</div></td>
					    </tr>
					</table>



<!-- 弹出采购详情-->
<div class='boxy' style="display:none; width:600px; height:500px;" id="boxy">  
                                            <div class="widget-body"><div class="widget-body-inner" style="display: block;">
                                                <div class="widget-main no-padding">
                                                    <table class="table table-bordered table-striped center">
                                                        <tbody id="tab_lists">
                                                            <tr>
                                                               <th width="25%">商品编号</th>
                                                               <th width="15%">商品数量</th>
                                                               <th width="15%">商品价格</th>
                                                               <th width="15%">小计</th>
                                                               <th width="10%">操作</th>

                                                            </tr>
                                                            </div>
                                                        </tbody>
                                                    </table>
                                                </div><!-- /widget-main -->
                                            </div></div><!-- /widget-body -->
<!--                                             <div class="footer_tab" style="float:right;margin:5px;">
                                             <button type="button" class="btn btn-sm btn-info" id="sub_tab" > 提交</button>
                                             <button type="button" class="btn btn-sm"  id="cancer" > 取消</button>
                                             </div> -->
                    </div>


<script type="text/javascript">


    $(function(){
        $("#tbmain tr").hover(function(){
            $(this).css({"background-color":"rgba(243, 236, 236, 0.72)"});
        },function(){
            $(this).css({"background-color":"#fff"});
        });

         $("#alldel").bind("click",checkSel);

    });

     function checkSel(){
       var flg= $(this).is(":checked");
       $("input[type='checkbox']").prop("checked",flg);
        if(flg){enable_all()}else{
          reduction_all();
        }
    }

/*   function selallval(){
     var _list="";
     $("#sample-table-2 input[type='checkbox']:checked").each(function(){
         // var flg=$(this).is(":checked");
         //if(!flg)return false;
         var _val=$(this).val();
         if(_val!=""){
         _list+= (_list==""?"":",")+"'"+_val+"'";
         } 
     });
     return _list;
} 
*/


    function _es_openDilog90(url, title,id){ 
     art.dialog.open(url, { title: title, width: '1000px', height: '80%', opacity: 0.2,lock: true, id: id, fixed: true, close:function(){load();}  });
}

function _es_openDilogSmall(url, title,id) {

    art.dialog.open(url, { title: title, width: '400px', height: '200px',lock: true, opacity: 0.2, id: id, fixed: true, close:function(){load();}  });

}
function goods_purchase(_this){
  // 检测是否填写数量
  var number =  $(_this).parent('td').prev().find('.number').val();
  if(number == "" || number == '0'){
     showvfmsg(0,"请先填写采购数量", 2000);return;
  }

  //弹出采购商品信息
  var goods_sn = $(_this).attr('goodssn');
  var goods_price = $(_this).attr('price');
  var htl = "<tr><td>"+goods_sn+"</td><td>"+number+"</td><td>"+goods_price+"</td><td>"+(number*goods_price).toFixed(2)+"</td><td></td></tr>";
  $('#tab_lists').append(htl);
   var url = $(_this).attr('url');
  quantity_price(url,number);



}

//提交前先计算所采购的数量价格
function quantity_price(url,number){

    var dialog = art.dialog({
    title: '采购详情',
    content: document.getElementById("boxy"),
    ok: function(){
                   _show_public_loading();
                       $.ajax({
                                 'url':url,
                                 'dataType':'json',
                                 'data':{Quantity:number},
                                 'type':'post',
                           success:function(data){
                              var retstatus = data.RetCode == 1 ? "0" : "1";
                              showvfmsg(retstatus, data.Message, 3000);
                              $('#money').html(data.money);
                              dialog.close();
                              if(retstatus=="0"){
                                //修改余额；
                                  reduction_all();
                              }
                             load();
                          },error:function(){
                               showvfmsg('error','请求服务器失败',2000);
                          },complete:function(){
                           _hide_public_loading();
                          }
                          });
    },
    cancelVal: '关闭',
    cancel:true,
    close:function(){
      load();
    }
});
/* var dialog = art.dialog();
              dialog.title('采购详情');
              dialog.lock(true);
              dialog.content(document.getElementById("boxy"));*/
/*              dialog.cancel(function(){
                  var htl = '<tr><th width="25%">商品编号</th><th width="25%">商品数量</th><th width="25%">商品价格</th><th width="25%">小计</th></tr>';
                     $('#tab_lists').html(htl);
                   });*/
             
              // close:function(){load();}
         /*     $("#cancer").click(function (){
                             dialog.close();
                             load();*/
                    /*         var htl = '<tr><th width="25%">商品编号</th><th width="25%">商品数量</th><th width="25%">商品价格</th><th width="25%">小计</th></tr>';
                     $('#tab_lists').html(htl);
               });   */
/*              $('#sub_tab').click(function() {


              });*/
}


//启用所有
function enable_all(){
    $("input[type='number']").each(function() {
       $(this).attr("disabled",false);
       $(this).parent('td').next().find('a').attr("disabled",false).addClass('btn-info');
       $(this).parent('td').parent('tr').children('td').eq(0).find('input').prop("checked",true);
       $('#batch_purchase').attr("disabled",false).addClass('btn-info');
  });

}
//还原所有
function reduction_all(){
    $("input[type='number']").each(function() {
       $(this).attr("disabled",true).val(0);
       $(this).parent('td').next().find('a').attr("disabled",true).removeClass('btn-info');
       $(this).parent('td').parent('tr').children('td').eq(0).find('input').prop("checked",false);
       $('#batch_purchase').attr("disabled",true).removeClass('btn-info');
  });

}
//启用或者禁用
function enable_disable(_this){
     var flg= $(_this).is(":checked");
     if(flg){
         $(_this).parent('td').nextAll().children(".sub_caigou").attr("disabled",false).addClass('btn-info');
         $(_this).parent('td').nextAll().children(".number").attr("disabled",false);
     }else{
         $(_this).parent('td').nextAll().children(".sub_caigou").attr("disabled",true).removeClass('btn-info');
         $(_this).parent('td').nextAll().children(".number").attr("disabled",true);
         $(_this).parent('td').nextAll().children(".number").val(0);
     }
     var i = 0;
    var j = false;
   $("#sample-table-2 .enable_disable:checked").each(function(){
       j = true;
       i++;
    })
    if(i>0){
      $('#batch_purchase').attr("disabled",false).addClass('btn-info');
    }else{
      $('#batch_purchase').attr("disabled",true).removeClass('btn-info');
      $('#alldel').prop("checked",false);
    }
}
</script>